<?php

namespace app\admin\command;

use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Exception;

use app\common\library\IMSHelper;
use app\common\library\FSHelper;

use app\admin\model\ImsVlan;

class ImsVlanInit extends Command {

    protected $imsHelper = null;

    protected $fsHelper = null;

    protected function configure() {
        $this->setName('imsvlaninit')
             ->setDescription('Initialize IMS Vlan');
    }

    protected function execute(Input $input, Output $output) {
        echo "Initializing IMS Vlan...\r\n";
        $cmd = "sed -i \/vlan\/d \/etc\/iproute2\/rt_tables";
        system($cmd);
        $imsHelper = new IMSHelper();
        $vlanList = ImsVlan::where('1=1')->select();
        foreach($vlanList as $one) {
            $imsHelper->addVlan($one->vlanid, $one);
        }
        echo "Initialize IMS Vlan Done!\r\n";
    }
}
